package br.ucb.sigplan.action.impl;

import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import br.ucb.sigplan.action.Action;
import br.ucb.sigplan.beans.Login;
import br.ucb.sigplan.beans.Turma;
import br.ucb.sigplan.crud.ProfessorCrud;
import br.ucb.sigplan.crud.TurmaCrud;

public class AbrirListarTurmaSelecaoAction implements Action {

	@Override
	public String execute(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		Login login = (Login) req.getSession().getAttribute("login");
		Integer idProfessor = ProfessorCrud.findByEmail(login.getEmail()).getIdProfessor();
		List<Turma> turmas = TurmaCrud.findByProfessor(idProfessor);
		req.getSession().setAttribute("turmas", turmas);
		return "/jsp/professor/plano/profEscolheTurmaAlterar.jsp";
	}

}